﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UMO.UmoControls
{
    /// <summary>
    /// Interaction logic for UmoNavigation.xaml
    /// </summary>
    public partial class UmoNavigation : UserControl
    {
        public UmoNavigation()
        { 
            InitializeComponent();
        }
        public MainWindow ParentWindow;
        public UmoNavigation(MainWindow parentWindow)
        {
            InitializeComponent();
            this.ParentWindow = parentWindow;
        }
      
        public void SetParentWindow(MainWindow parentWindow)
        {
            this.ParentWindow = parentWindow;
        }
        private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            if (this.ParentWindow != null)
            {
            ParentWindow.scaleTransform.ScaleX = e.NewValue;
            ParentWindow.scaleTransform.ScaleY = e.NewValue;
                var centerOfViewport = new Point(ParentWindow.TrackScrollViewer.ViewportWidth / 2,
                                                 ParentWindow.TrackScrollViewer.ViewportHeight / 2);
                ParentWindow.lastCenterPositionOnTarget = ParentWindow.TrackScrollViewer.TranslatePoint(centerOfViewport, ParentWindow.MainGrid);
            }
        }

    }
}
